<template>
	<view class="container flex justify-center">
		<iframe v-if="!ismobile" :src="url" frameborder="0" :style="'width:'+width"></iframe>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: '',
				width: '',
				ismobile: true,
			};
		},
		onLoad(opt) {
			// #ifdef MP-WEIXIN
			
			console.log('微信!!!!!!!!!!')
			uni.switchTab({
				url: `/pages/index/index`,
				fail(err) {
				console.log(err);
				}
			})
			return 1
			// #endif
			
			this.ismobile = this.isMobile();
			let url = 'pages/index/index'; //你的首页
			console.log('this.ismobile ---', this.ismobile, `${location.href}${url}`)
			
			if(this.ismobile){
				uni.switchTab({
					url: `/${url}`,
					fail(err) {
					console.log(err);
					}
				})
			}else{
				// ifndef H5
				window.location.href = 'http://bodexiong.vip:32101/';
				// endif
				uni.switchTab({
					url: `/${url}`,
					fail(err) {
					console.log(err);
					}
				})
				// this.url = `${location.href}${url}`;
				// this.width = '375px';
				// setTimeout(() => {
				//  this.width = '100%';
				// },300)
			}
		},
		onShow() {
			
		},
		methods:{
			isMobile() {
		        let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
		        return flag?true:false;
	        }
		}
	};
</script>

<style lang="scss">
	.container{
		height: 100%;
		iframe{
			display: block;
			width: 375px;
			height: 100%;
			opacity: 0;
			animation: fadeShow .3s ease-in forwards .3s;
		}
	}
	@keyframes fadeShow {
		0% {
			opacity: 0;
		}
		100%{
			opacity: 1;
		}
	}
</style>